<?php 
include_once 'head.php';

//Index Controller 
if( $_SERVER['REQUEST_METHOD'] == 'POST'){
    
    try {
        if($auth->login( trim($_POST['uname']),  $_POST['pass'])) {
            header("Location:welcome.php");            
        } else {
            $msg="Please enter correct username / password";        
        }
        
    } catch (LoginException $e) {
        $msg = $e->getMessage();
    }
}

if (isset($_SESSION['register_success'])) {
    $registerSuccess = $_SESSION['register_success'];
    unset($_SESSION['register_success']);
?>

<div class="register_success_message">Your registration request was received. 
    You will be able to log in to the system once it is approved by an administrator.
</div>

<?php } ?>


<br /><br />

 <img title="chims@lrh" alt="chims@lrh" src="img/chims.png"></img><br /><br /><br />
   
  <form autocomplete="off"  action="index.php" method = "post">
    <table id="login">
      <?php if (isset($msg)) { ?> <tr><td colspan='2'> <div class="message error"> <?php echo $msg; ?> </div> </td></tr> <?php } ?>
      <tr><td>Username:</td><td><input type="text" maxlength="50" size="25" name="uname" class="input"></td></tr>
      <tr><td>Password:</td><td><input type="password" size="25" value="" name="pass" class="input"></td></tr>
      <tr><td></td><td align="right"><input type="submit" value="Log In" name="log" class="button"></td></tr>
      <!--<tr><td></td><td class="l"><div class="s"><a href="help.php">I forgot my password</a></div></td></tr>-->
    </table>
  </form>
<?php include_once 'foot.php'; ?>